﻿using GalaSoft.MvvmLight;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VisionApp.Entity
{
    public class VSCfgData : ObservableObject
    {
        private string _tx;
        public string Tx
        {
            get
            {
                return _tx;
            }
            set
            {
                Set<string>(ref _tx, value);
            }
        }
        private string _ty;
        public string Ty
        {
            get
            {
                return _ty;
            }
            set
            {
                Set<string>(ref _ty, value);
            }
        }
        private string _tz;
        public string Tz
        {
            get
            {
                return _tz;
            }
            set
            {
                Set<string>(ref _tz, value);
            }
        }
        private string _rz;
        public string Rz
        {
            get
            {
                return _rz;
            }
            set
            {
                Set<string>(ref _rz, value);
            }
        }
        private string _rx;
        public string Rx
        {
            get
            {
                return _rx;
            }
            set
            {
                Set<string>(ref _rx, value);
            }
        }
        private string _ry;
        public string Ry
        {
            get
            {
                return _ry;
            }
            set
            {
                Set<string>(ref _ry, value);
            }
        }
        public string PoseResult;

        private double _threshold;
        public double Threshold
        {
            get
            {
                return _threshold;
            }
            set
            {
                Set<double>(ref _threshold, value);
            }
        }
        private int _width;
        public int Width
        {
            get
            {
                return _width;
            }
            set
            {
                Set<int>(ref _width, value);
            }
        }
        private int _height;
        public int Height
        {
            get
            {
                return _height;
            }
            set
            {
                Set<int>(ref _height, value);
            }
        }

        public List<string> AvailableColor
        {
            get
            {
                List<string> colors = new List<string>();
                colors.Add("White");
                colors.Add("Gray");
                colors.Add("Blue");
                colors.Add("Black");
                return colors;
            }
        }

        private string _color = "White";
        public string Color
        {
            get
            {
                return _color;
            }
            set
            {
                Set<string>(ref _color, value);
            }
        }

        private long _ngCnt;
        public long NGCnt
        {
            get
            {
                return _ngCnt;
            }
            set
            {
                Set<long>(ref _ngCnt, value);
                refreshPassRate();
            }
        }

        private long _okCnt;
        public long OKCnt
        {
            get
            {
                return _okCnt;
            }
            set
            {
                Set<long>(ref _okCnt, value);
                refreshPassRate();
            }
        }

        private double _passRate;
        public double PassRate
        {
            get
            {
                return _passRate;
            }
            set
            {
                Set<double>(ref _passRate, value);
            }
        }
        private double _fps=1;
        public double FPS
        {
            get
            {
                return _fps;
            }
            set
            {
                Set<double>(ref _fps, value);
            }
        }

        private void refreshPassRate()
        {
            if ((OKCnt + NGCnt) == 0)
            {
                return;
            }
            PassRate = 1.0 * OKCnt / (OKCnt + NGCnt);
        }
    }
}
